package model;

import java.util.Date;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;

import services.UserData;
import utils.Utils;

public class UserDataWrapper {

	private Integer id = -1;
	private Integer userid = -1;
	private LocalDate date = new LocalDate();
	private DateTime startTime = new DateTime();
	
	private DateTime endTime = new DateTime();
	
	private String note;
	
	public UserDataWrapper() {
	}
	public UserDataWrapper(Integer id, Integer userid,Date date, Date startTime, Date endTime, String note) {
		this.id = id;
		this.userid = userid;
		this.date = new LocalDate(date.getTime());
		this.startTime = new DateTime(startTime);
		this.endTime = new DateTime(endTime);
		this.note = note;
	}
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getUserId() {
		return userid;
	}

	public void setUserId(Integer id) {
		this.userid = id;
	}
	public DateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(DateTime startTime) {
		this.startTime = startTime;
	}

	public DateTime getEndTime() {
		return endTime;
	}

	public void setEndTime(DateTime endTime) {
		this.endTime = endTime;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}
	public static UserDataWrapper wrap(UserData data) {
		return new UserDataWrapper(data.getId(), data.getUserid(), data.getDate().getTime(), data.getStartTime().getTime(),
				data.getEndTime().getTime(), data.getNote());
	}
	public UserData toUserData() {
		return new UserData(Utils.dateToCalendar(date.toDate()),Utils.dateToCalendar(endTime.toDate()), 
				id, note, Utils.dateToCalendar(startTime.toDate()), userid);
	}
	public LocalDate getDate() {
		return date;
	}
	public void setDate(LocalDate date) {
		this.date = date;
	}
}
